<script setup>
import {computed} from "vue";
import {message} from "ant-design-vue";
const baseUrl = computed(() => import.meta.env.VITE_BASE_URL + 'system/basic/postUploadOne')
const emit = defineEmits(["upload"]);

const change = (e) => {
  const { file } = e
  if (file.status === 'done') {
    if (file.response.code === 1) {
      emit('upload', file.response)
    } else {
      message.error(file.response.info)
    }
  }
}
</script>

<template>
  <div class="up-b">
    <a-upload
      accept=".png,.jpg,.jpeg,.webp"
      name="img"
      list-type="picture-card"
      :show-upload-list="false"
      :action="baseUrl"
      @change="change"
    >
      <slot></slot>
    </a-upload>
  </div>
</template>

<style scoped lang="scss">
  .up-b {
    width: 100px;
    height: 100px;
  }
  :deep(.ant-upload) {
    margin: 0 !important;
  }
</style>